//app.js

App({

  onLaunch: function(op) {
    console.log(op);
    wx.login({
      success: function(res) {
        console.log(res.code);
        //发送请求
        wx.request({
          url: 'https://zhangyushu.liangziqishi.shop/api/app/login', //接口地址
          data: {
            code: res.code,
            userId: op.query.userId
          },
          method: 'POST',
          header: {
            'content-type': 'application/json' //默认值
          },
          success: function(res) {
            
            console.log(res.data.data.data.accessToken);
            // wx.setStorageSync("session_key", res.data.data.data.session_key);
            wx.setStorageSync("sessionId",res.data.data.data.sessionId);
            wx.setStorageSync("openid", res.data.data.data.openid);
            wx.setStorage({
              key: 'sessionId',
              data: res.data.data.data.accessToken,
            });
          }
        });
      }
    })
    // 展示本地存储能力
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
    var that = this

  },



  globalData: {
    userInfo: null,
  }
})